package net.butfly.albacore.helper.async;

import net.butfly.albacore.helper.AsyncHelper;
import net.butfly.albacore.helper.HelperBase;

import org.springframework.core.task.TaskExecutor;

public class AsyncHelperSpringImpl extends HelperBase implements AsyncHelper {
	private static final long serialVersionUID = -1372378392364218536L;
	private TaskExecutor executor;

	public void setExecutor(TaskExecutor executor) {
		this.executor = executor;
	}

	public Thread execute(AsyncTaskBase task) throws AsyncTaskException {
		Thread t = new RunnableTask(task);
		this.executor.execute(t);
		return t;
	}
}
